import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.Component;
import javax.swing.Box;
import javax.swing.JTextArea;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Date;



public class NewPatientGUI extends JPanel {
    int location;
    User newUser;
    private JTextField textField;
    private JTextField textField_1;
    private JTextField textField_2;
    private JTextField textField_3;
    private JTextField textField_4;
    private JTextField textField_5;
    private JTextField textField_6;
    private JTextField textField_7;
    private JTextField textField_8;
    private JTextField textField_9;
    private JTextField textField_10;
    private JTextField textField_11;
    private JTextField textField_12;
    public NewPatientGUI() {
        setLayout(null);
        newUser = new User();
        JLabel lblName = new JLabel("Name");
        lblName.setBounds(12, 8, 111, 14);
        add(lblName);
        
        textField = new JTextField();
        textField.setBounds(140, 2, 86, 20);
        add(textField);
        textField.setColumns(10);
        
        JLabel lblAddress = new JLabel("Address");
        lblAddress.setBounds(236, 8, 99, 14);
        add(lblAddress);
        
        textField_1 = new JTextField();
        textField_1.setBounds(345, 8, 86, 20);
        add(textField_1);
        textField_1.setColumns(10);
        
        JLabel lblNewLabel = new JLabel("Phone");
        lblNewLabel.setBounds(9, 33, 114, 14);
        add(lblNewLabel);
        
        textField_2 = new JTextField();
        textField_2.setBounds(140, 27, 86, 20);
        add(textField_2);
        textField_2.setColumns(10);
        
        JLabel lblCell = new JLabel("Cell");
        lblCell.setBounds(236, 33, 99, 14);
        add(lblCell);
        
        textField_3 = new JTextField();
        textField_3.setBounds(345, 33, 86, 20);
        add(textField_3);
        textField_3.setColumns(10);
        
        JLabel lblEmail = new JLabel("Email");
        lblEmail.setBounds(15, 58, 108, 14);
        add(lblEmail);
        
        textField_4 = new JTextField();
        textField_4.setBounds(140, 52, 86, 20);
        add(textField_4);
        textField_4.setColumns(10);
        
        JLabel lblNewLabel_1 = new JLabel("Gender");
        lblNewLabel_1.setBounds(236, 58, 99, 14);
        add(lblNewLabel_1);
        
        textField_5 = new JTextField();
        textField_5.setBounds(345, 58, 86, 20);
        add(textField_5);
        textField_5.setColumns(10);
        
        JLabel lblNewLabel_2 = new JLabel("Pharmacy");
        lblNewLabel_2.setBounds(10, 83, 113, 14);
        add(lblNewLabel_2);
        
        textField_6 = new JTextField();
        textField_6.setBounds(138, 77, 86, 20);
        add(textField_6);
        textField_6.setColumns(10);
        
        JLabel lblInsurance = new JLabel("Insurance");
        lblInsurance.setBounds(229, 83, 106, 14);
        add(lblInsurance);
        
        textField_7 = new JTextField();
        textField_7.setBounds(347, 83, 86, 20);
        add(textField_7);
        textField_7.setColumns(10);
        
        JLabel lblAllergies = new JLabel("Allergies");
        lblAllergies.setBounds(12, 110, 87, 14);
        add(lblAllergies);
        
        JLabel lblRole = new JLabel("Username");
        lblRole.setBounds(15, 171, 96, 14);
        add(lblRole);
        
        textField_8 = new JTextField();
        textField_8.setBounds(113, 196, 86, 20);
        add(textField_8);
        textField_8.setColumns(10);
        
        JButton btnCreate = new JButton("Create");
        btnCreate.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                location = 14;
                newUser.setAddress(textField_1.getText());
                newUser.setAllergies(textField_10.getText());
                newUser.setInsurance(textField_7.getText());
                newUser.setBirthDate(Date.valueOf(textField_11.getText()));
                newUser.setSSN(Integer.parseInt(textField_12.getText()));
                newUser.setEmail(textField_4.getText());
                newUser.setCellPhone(textField_3.getText());
                newUser.setPhone(textField_2.getText());
                newUser.setUserName(textField_9.getText());
                newUser.setPassword(textField_8.getText());
                newUser.setName(textField.getText());
                boolean[] roles;
                roles = new boolean[4];

                roles[0] = true;
                roles[1] = false;
                roles[2] = false;
                roles[3] = false;
                
                newUser.setRoles(roles);
                
            }
        });
        btnCreate.setBounds(10, 251, 130, 23);
        add(btnCreate);
        
        JButton btnCancel = new JButton("Cancel");
        btnCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                location = -1;
            }
        });
        btnCancel.setBounds(201, 251, 134, 23);
        add(btnCancel);
        
        JLabel lblPassword = new JLabel("PassWord");
        lblPassword.setBounds(12, 196, 96, 14);
        add(lblPassword);
        
        textField_9 = new JTextField();
        textField_9.setColumns(10);
        textField_9.setBounds(113, 168, 86, 20);
        add(textField_9);
        
        textField_10 = new JTextField();
        textField_10.setColumns(10);
        textField_10.setBounds(113, 107, 318, 50);
        add(textField_10);
        
        JLabel lblBirthdate = new JLabel("BirthDate");
        lblBirthdate.setBounds(268, 196, 96, 14);
        add(lblBirthdate);
        
        textField_11 = new JTextField();
        textField_11.setColumns(10);
        textField_11.setBounds(369, 196, 86, 20);
        add(textField_11);
        
        JLabel lblSsn = new JLabel("SSN");
        lblSsn.setBounds(268, 165, 96, 14);
        add(lblSsn);
        
        textField_12 = new JTextField();
        textField_12.setColumns(10);
        textField_12.setBounds(369, 165, 86, 20);
        add(textField_12);
    }
    public int getLoc(){
        return location;
    }
    
    public void setLoc(int i){
        location = i;
    }
    public void setUser(User input){
        newUser = input;
    }
    public User getUser()
    {
        return newUser;
    }
}
